let THREE=require('three');
import ParticleCube from './particle_cube';

const FRACTION=(num,mul=1)=>{
    let n=num*mul;
    return n-Math.floor(n);
};

export default class ParticleRound extends ParticleCube{
    constructor(values={}){
        super(values);
    }
    initVariable(){
        super.initVariable();
        this.direction=new THREE.Vector3();
    }
    setStartVertSpeed(rand,i,t){
        let x=-this.props.startSize.value+this.props.startSize.value*2*FRACTION(rand,1e4);
        let z=-this.props.startSize.value+this.props.startSize.value*2*FRACTION(rand,1e5);
        let l=FRACTION(rand,1e6)*this.props.startSize.value;
        this.direction.set(x,0,z).normalize().multiplyScalar(l);
        this.verts[i]=this.direction.x;
        this.verts[i+2]=this.direction.z;

        this.speeds[i]=this.verts[i]*this.endScl-this.verts[i];
        this.speeds[i+1]=this.props.speedMin.value+(this.props.speedMax.value-this.props.speedMin.value)*FRACTION(rand,1e7);
        this.speeds[i+2]=this.verts[i+2]*this.endScl-this.verts[i+2];
    }
}